package IO.Buffered;

import java.io.*;

/**
 * 文件输入输出流达到文件的拷贝
 */
public class CopyTxt {
    public static void copy(String srcPath,String destPath){
        //创建源
        File src = new File(srcPath);//源头
        File dest = new File(destPath);//目的地
        //选择流

        //读取
        try (BufferedReader br = new BufferedReader(new FileReader(src));
                BufferedWriter bw = new BufferedWriter(new FileWriter(dest))){
            String line = null;
            while ((line=br.readLine())!=null){
                bw.write(line);
                bw.newLine();
                bw.flush();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    public static void main(String[] args) {
        copy("src/IO/abc.txt","src/IO/dest.txt");
    }
}
